#!/bin/bash
#
#  /etc/init.d/plannerd
#
# Starts the sender daemon
#
# chkconfig: 345 95 5
# description: Runs planner.php.
# processname: plannerd
 
# Source function library.
. /etc/init.d/functions
 
#startup values
log=/home/magneto/deamons/planner.log
 
#verify that the executable exists
test -x /home/magneto/daemons/planner.php || exit 0RETVAL=0
 
#
#   Set prog, proc and bin variables.
#
prog="planner"
proc=/home/magneto/daemons/planner_lock
bin=/home/magneto/daemons/planner.php
 
start() {
    # Check if planner is already running
    if [ ! -f $proc ]; then
        echo -n $"Starting $prog: "
        daemon $bin
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $proc
        echo
    else
        echo $"Planner already running"
    fi
 
    return $RETVAL
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $bin
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f $proc
    echo
        return $RETVAL
}
 
restart() {
    stop
    start
}   
 
status_at() {
    status $bin
}
 
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    status)
        status_at
        ;;
    *)
     
    echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac
 
exit $?
exit $RETVAL
